<template>
  <div class="index">
    <div class="main w1200">
      <div class="main-box">
        <!-- 轮播图 -->
        <div class="main-box-left">
          <el-carousel trigger="click" width='650px' height="380px">
            <el-carousel-item v-for="(item,index) in shuffingImgList" :key="index">
              <a target="_blank" :href="item.webUrl" class="cur" style="display: block">
                <img :src="item.imgUrl" style="width:100% ;height: 380px">
              </a>
            </el-carousel-item>
          </el-carousel>
        </div>
        <!-- 科学竞赛 -->
        <div class="main-box-right">
          <div class="right-box">
            <div class="box-top">
              <div>
                <span class="competition">学科竞赛</span>
              </div>
              <div class="flex">
                <span class="discipline flex1">Discipline Competition</span>
                <span class="more cur" style="color:#3246c4; font-size: 16px; font-weight:600" @click="DisciplineMore">查看更多+</span>
              </div>
            </div>
            <div class="box-bottom">
              <div class="bottom-box">
                <div class="competition-box cur" v-for="(item,index) in courseContestsList" :key="index" v-if="index<3" @click="courseContests(item)">
                  <div class="competition-img">
                    <!-- <img src="../assets/images/xkjs_1.jpg" class="img"> -->
                    <img :src="item.articleImg" class="img">
                  </div>
                  <div class="competition-text">
                    <p :style='ruturnColor(item.titleColor)'>{{item.title}}</p>
                    <div class="text-time">{{createdTime}}</div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
    <!-- 大赛专区 -->
    <div class="regional">
      <div class="regional-box w1200">
        <div class="regional-box-top">
          <div class="box-left">
            <div class="box-left-top">大赛专区</div>
            <div class="box-left-bottom">Contest area</div>
          </div>
          <div class="box-right">
            <div class="flex box-right">
              <div class="cur box-right-box" style="margin-right: 10px; float: left;" @click='linkTo("first")'>大赛介绍➡</div>
              <div class="cur box-right-box" @click='linkTo("third")' style="float:right;">大赛流程➡</div>
            </div>
          </div>
        </div>
        <div class="regional-box-more">
          <div class="box-more-bottom">
            <div class=" bottom ">
              <div class="flex" style="width: 320px; border-bottom: 2px solid #eeeeee;">
                <div class="box-more-text cur" @mouseenter="zp(1)" @mouseleave="out" :class="this.bcg == 1 ?'color324':''">参赛队伍与作品</div>
                <div class="box-more-text cur" style="margin-left:50px; width: 150px"
                @mouseenter="zs(2)" @mouseleave="out" :class="this.bcg == 2 ?'color324':''"
                >获奖队伍及做作品展示</div>
              </div>
            </div>
            <div class="box-more-end cur" @click="Contestmore">查看更多+</div>
          </div>
          <div class="box-list flex" v-if="this.bcg == 1" >
            <div class="list-box cur" v-for="(item,index) in participatingWorksList" :key="index" v-if="index<4" @click="zps(item)">
              <div class="list-box-images">
                <img :src="item.articleImg" class="img">
              </div>
              <div class="list-box-list">
                <div class="box-li flex">
                  <div class="dwmc-img">
                    <img src="../assets/images/dwmc.png" class="img">
                  </div>
                  <div class="ranksName">队伍名称:
                    <span style="color: #929292">{{item.teamName}}</span>
                  </div>
                </div>
                <div class="box-li flex">
                  <div class="dwmc-img">
                    <img src="../assets/images/csdw.png" class="img">
                  </div>
                  <div class="ranksName">参赛单位:
                    <span style="color: #929292">{{item.participatingUnits}}</span>
                  </div>
                </div>
                <div class="box-li flex">
                  <div class="dwmc-img">
                    <img src="../assets/images/tdcy.png" class="img">
                  </div>
                  <div class="ranksName">团队成员:
                    <span style="color: #929292">{{item.teamMember}}</span>
                  </div>
                </div>
                <div class="box-li flex">
                  <div class="dwmc-img">
                    <img src="../assets/images/cstm.png" class="img">
                  </div>
                  <div class="ranksName">赛题名称:
                    <span style="color: #929292">{{item.worksName}}</span>
                  </div>
                </div>
              </div>
            </div>
          </div>
          <div class="box-list flex" v-if="this.bcg == 2">
            <div class="list-box cur" v-for="(item,index) in victoryWorksList" :key="index" v-if="index<4" @click="zss(item)">
              <div class="list-box-images">
                <img :src="item.articleImg" class="img">
              </div>
              <div class="list-box-list">
                <div class="box-li flex">
                  <div class="dwmc-img">
                    <img src="../assets/images/dwmc.png" class="img">
                  </div>
                  <div class="ranksName">队伍名称:
                    <span style="color: #929292">{{item.teamName}}</span>
                  </div>
                </div>
                <div class="box-li flex">
                  <div class="dwmc-img">
                    <img src="../assets/images/csdw.png" class="img">
                  </div>
                  <div class="ranksName">参赛单位:
                    <span style="color: #929292">{{item.participatingUnits}}</span>
                  </div>
                </div>
                <div class="box-li flex">
                  <div class="dwmc-img">
                    <img src="../assets/images/tdcy.png" class="img">
                  </div>
                  <div class="ranksName">团队成员:
                    <span style="color: #929292">{{item.teamMember}}</span>
                  </div>
                </div>
                <div class="box-li flex">
                  <div class="dwmc-img">
                    <img src="../assets/images/cstm.png" class="img">
                  </div>
                  <div class="ranksName">赛题名称:
                    <span style="color: #929292">{{item.worksName}}</span>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="lecture">
      <div class="lecture-box w1200 flex">
        <!-- 讲座论坛 -->
        <div class="lecture-box-left">
          <div class="box-left-top">
            <div>
              <span class="competition">讲座论坛</span>
            </div>
            <div class="flex">
              <span class="discipline flex1">Lecture Forum</span>
              <span class="more cur align-items_flex-end" style="color:#3246c4; font-size: 16px; font-weight:600; float:right;" @click="Lecturemore">查看更多+</span>
            </div>
          </div>
          <div class="box-left-bottom">
            <div class="" style="flex-wrap: wrap-reverse;">
              <div class="box-list cur" v-for="(item,index) in lectureList" :key="index" v-if="index<6" @click="lt(item)">
                <div class="box-list-img">
                  <img :src="item.articleImg" class="img">
                </div>
                <div class="box-list-text" :style='ruturnColor(item.titleColor)'>
                  {{item.title}}
                </div>
              </div>
            </div>
          </div>
        </div>
        <div class="lecture-box-right">
          <div class="box-left-top">
            <div>
              <span class="competition">创新创业</span>
            </div>
            <div class="flex">
              <span class="discipline flex1">Inonvation and entrepreneurship</span>
              <span class="more cur" style="color:#3246c4; font-size: 16px; font-weight:600;float:right" @click="Inonvation">查看更多+</span>
            </div>
          </div>
          <div class="box-left-bottom">
           <div class="box-list flex cur" v-for="(item,index) in innovationList" :key="index" @click="cxcy(item)"v-if="index<4">
              <div class="box-img">
                <img :src="item.articleImg"  style="min-width: 100%">
              </div>
              <div class="box-text">
                <div class="box-text-top flex">
                  <span class="flex1" :style='ruturnColor(item.titleColor)' style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;">{{item.title}}</span>
                  <span class="box-text-time" style="float: right;">{{createdTime}}</span>
                </div>
                <div class="box-text-bottom">
                  <p>
                    {{item.context}}
                  </p>
                </div>
              </div>
           </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
  import {bus} from '../bus'
  import navs from '../components/common/nav'
  import foot from '../components/common/footer'
  import API from '../api/content.js'
  export default {
    components:{ navs,foot },
    data() {
      return {
        bcg:1,
        articleType:'',
        jumpType:'',
        createdTime:'',
        topImgList:'',//首页轮播图
        shuffingImgList:'',//轮播图
        courseContestsList:'',//科学竞赛
        participatingWorksList:'',//大赛专区-参赛作品
        victoryWorksList:'', //大赛专区--获奖作品
        lectureList:'',//讲座论坛
        innovationList:'',//创新创业,
        linkList:'',//友情链接
      }
    },
    mounted() {
      this.content()
    },
    methods:{
      ruturnColor(color){
        return color?`color:${color};`:'color:#000;'
      },
      linkTo(name){
        let routeUrl = this.$router.resolve({
          path: "/match",
          query:{activeName:name,articleType:3}
        });
         window.open(routeUrl.href, '_blank');
        this.$store.commit('setChange',3)
      },
      funcUrlAdd(params, val) {
        let query = this.$route.query;
        let path = this.$router.history.current.path;
        let newQuery = JSON.parse(JSON.stringify(query));
          for(let i in newQuery) {
            if(i == params && newQuery[i] == val) return;
          }
          newQuery[params] = val;
        this[params] = val; // 赋值
        this.$router.replace(
          {path, query: newQuery}
        );
        this.content()
      },
      zp(e) {
        this.bcg = e
      },
      zs(e) {
        this.bcg = e
      },
      out() {
        this.menu = ''
      },
      DisciplineMore() {
        let routeUrl = this.$router.resolve({
          path: "/competition",
          query: {articleType:2}
        });
         window.open(routeUrl.href, '_blank');
      },
      Contestmore() {
        let routeUrl=''
        if(this.bcg == 1){
          routeUrl = this.$router.resolve({
            path: "/match",
            query:{activeName:'second',articleType:3}
          });
        }else if(this.bcg == 2){
          routeUrl = this.$router.resolve({
            path: "/match",
            query:{activeName:'last',articleType:3}
          });
        }
        
         window.open(routeUrl.href, '_blank');
        this.$store.commit('setChange',3)

        // let routeUrl = this.$router.resolve({
        //   path: "/match",
        //   query: {articleType:3}
        // });
        //  window.open(routeUrl.href, '_blank');
      },
      Lecturemore() {
        let routeUrl = this.$router.resolve({
          path: "/forum",
          query: {articleType:4}
        });
        window.open(routeUrl.href, '_blank');
      },
      Inonvation() {
        let routeUrl = this.$router.resolve({
          path: "/innovate",
          query: {articleType:5}
        });
        window.open(routeUrl.href, '_blank');
      },
      content() {
        API.WebsiteData().then(res =>{
          if(res.code == 0 ) {
            this.topImgList = res.data.topImgList
            this.shuffingImgList = res.data.shuffingImgList
            this.courseContestsList = res.data.courseContestsList 
            this.participatingWorksList  = res.data.participatingWorksList
            this.victoryWorksList = res.data.victoryWorksList
            this.lectureList = res.data.lectureList
            this.innovationList = res.data.innovationList
            this.linkList = res.data.linkList
          }
          for(let i in this.courseContestsList) {
            this.createdTime = this.courseContestsList[i].createTime.split(" ")[0].toString()
          }  
          for(let i in this.innovationList) {
            this.createdTime = this.innovationList[i].createTime.split(" ")[0].toString()
          }
           this.$store.commit('linkList',this.linkList)
           this.$store.commit('topImgList',this.topImgList)
        })
      },
      courseContests(item) {
        if(item.articleBelongsType == 1){
          let webUrl = item.webUrl
          window.open(webUrl, '_blank');
        }else if(item.articleBelongsType == 2) {
          let routeUrl = this.$router.resolve({
            path: "/Detailid",
            query: {articleId:item.articleId,navName:'科学竞赛'}
          });
          window.open(routeUrl.href, '_blank');
        }
      },
      zps(item) {
        if(item.articleBelongsType == 1){
          let webUrl = item.webUrl
          window.open(webUrl, '_blank');
        }else if(item.articleBelongsType == 2) {
          let routeUrl = this.$router.resolve({
            path: "/dsdetails",
            query: {articleId:item.articleId,navName:'大赛详情'}
          });
          window.open(routeUrl.href, '_blank');
        }
      },
      zss(item) {
        if(item.articleBelongsType == 1){
          let webUrl = item.webUrl
          window.open(webUrl, '_blank');
        }else if(item.articleBelongsType == 2) {
          let routeUrl = this.$router.resolve({
            path: "/dsdetails",
            query: {articleId:item.articleId,navName:'大赛详情'}
          });
          window.open(routeUrl.href, '_blank');
        }
      },
      lt(item) {
        if(item.articleBelongsType == 1){
          let webUrl = item.webUrl
          window.open(webUrl, '_blank');
        }else if(item.articleBelongsType == 2) {
          let routeUrl = this.$router.resolve({
            path: "/Detailid",
            query: {articleId:item.articleId,navName:'讲座论坛'}
          });
          window.open(routeUrl.href, '_blank');
        }
      },
      cxcy(item) {
        if(item.articleBelongsType == 1){
          let webUrl = item.webUrl
          window.open(webUrl, '_blank');
        }else if(item.articleBelongsType == 2) {
          let routeUrl = this.$router.resolve({
            path: "/Detailid",
            query: {articleId:item.articleId,navName:'创新创业'}
          });
          window.open(routeUrl.href, '_blank');
        }
      }
    }
  }
</script>

<style lang="scss">
  .index {
    .main {
      margin-top: 30px;
      // height: 1000px;
      .main-box {
        overflow: hidden;
        .main-box-left {
          width: 650px;
          height: 380px;
          float: left;
        }
        .main-box-right {
          width: 550px;
          height: 380px;
          box-sizing: border-box;
          float: right;
          // background-color: red;
          padding-left: 14px;
          .right-box {
            .box-top {
              height: 45px;
              // background-color: red;
              padding-left: 6px;
              border-left:4px solid #3246c4 ;
              .competition {
                font-size: 19px;
                color: #555555;
                font-weight: 600;
              }
              .discipline {
                font-size: 15px;
                color: #555555;
              }
              .more {
                float: right;
              }
            }
            .box-bottom{
              width: 100%;
              height: 100%;
              margin-top: 35px;
              .bottom-box {
                .competition-box {
                  width: 170px;
                  height: 298px;
                  border: 1px solid #eeeeee;
                  margin-right: 10px;
                  float: left;
                  .competition-img {
                    width: 170px;
                    height: 200px;
                  }
                  .competition-text {
                    height: 100px;
                    padding: 15px 10px;
                    box-sizing: border-box;
                    p {
                      color: #555555;
                      font-size: 16px;
                      font-weight: 600;
                      white-space: nowrap;
                      overflow: hidden;
                      text-overflow: ellipsis;
                    }
                    .text-time {
                      margin-top: 10px;
                      color: #888888;
                    }
                  }
                }
                .competition-box:nth-child(3) {
                    margin-right: 0px;
                }
              }
            }
          }
        }
      }
    }
    .regional {
      margin-top: 35px;
      height: 570px;
      background-color: #f1f2f3;
      .regional-box {
        padding: 20px 0 35px 0;
        .regional-box-top {
          height: 45px;
          // background-color: red;
          padding-left: 6px;
          border-left: 4px solid #3246c4;
          .box-left {
            float: left;
            .box-left-top {
              font-size: 19px;
              color: #636464;
              font-weight: 600;
            }
            .box-left-bottom {
              margin-top: 4px;
              color: #555555;
              font-size: 14px;
            }
          }
          .box-right {
            // align-items: flex-end;
            float: right;
            .box-right-box {
              color: #FFFFFF;
              width: 160px;
              height: 45px;
              font-size: 14px;
              line-height: 45px;
              text-align: center;
              background: linear-gradient(to bottom,#6688d4,#9b5be5);
            }
          }
        }
        .regional-box-more {
          margin-top: 30px;
          padding-left: 6px;
          width: 100%;
          float: left;
          .box-more-bottom {
            overflow: hidden;
            .bottom {
              width: 105px;
              float: left;
              .box-more-text {
                text-align: center;
                font-size: 15px;
                padding: 20px 0;
                float: left;
              }
            }
            .box-more-end {
              color: #3246c4;
              font-weight: 600;
              float: right;
            }
          }
          .box-list {
            margin-top: 24px;
            .list-box {
              width: 290px;
              height: 344px;
              margin-right: 13px;
              float: left;
              // background-color: red;
              .list-box-images {
                width: 290px;
                height: 210px;
              }
              .list-box-list {
                background-color: #fff;
                padding: 5px 0 17px 12px;
                .box-li {
                  align-items: center;
                  padding: 6px 0;
                  .dwmc-img {
                    width: 19px;
                    height: 16px;
                    float: left;
                  }
                }
                .ranksName {
                  width: 100%;
                  white-space:nowrap;
                  overflow: hidden;
                  text-overflow: ellipsis;
                  padding-left: 10px;
                }
              }
            }
            .list-box:nth-child(4) {
              margin-right: 0;
            }
          }
        }
      }
    }
    .lecture {
      height: 570px;
      
      .lecture-box {
        padding: 36px 0 72px 0;
        .lecture-box-left {
          width: 650px;
          float: left;
          .box-left-top {
            height: 45px;
            padding-left: 6px;
            border-left: 4px solid #3246c4;
            .competition {
              font-size: 19px;
              color: #555555;
              font-weight: 600;
            }
            .discipline {
              font-size: 15px;
              color: #555555;
            }
          }
          .box-left-bottom {
            margin-top: 15px;
            .box-list {
              border: 1px solid #dddddd;
              width: 210px;
              height: 185px;
              margin-top: 15px;
              margin-right: 7px;
              float: left;
              // background-color: red;
              .box-list-img {
                height: 145px;
                img {
                  width: 100%;
                  height: 100%;
                }
              }
              .box-list-text {
                white-space: nowrap;
                overflow: hidden;
                text-overflow: ellipsis;
                text-align: center;
                height: 40px;
                line-height: 40px;
                color: #555555;
                font-weight: 600;
              }
            }
            .box-list:nth-child(3n) {
              margin-right: 0px;
            }
          }
        }
        .lecture-box-right {
          width: 530px;
          margin-left: 20px;
          float: right;
          .box-left-top {
            height: 45px;
            padding-left: 6px;
            border-left: 4px solid #3246c4;
            .competition {
              font-size: 19px;
              color: #555555;
              font-weight: 600;
            }
            .discipline {
              font-size: 15px;
              color: #555555;
            }
          }
          .box-left-bottom {
            margin-top: 30px;
            .box-list {
              width: 530px;
              height: 82px;
              margin-bottom: 20px;
            }
            .box-list:nth-child(4) {
              margin-bottom: 0px;
            }
            .box-img {
              width: 110px;
              height: 83px;
              float: left;
              img {
                width: 100%;
                height: 100%;
              }
            }
            .box-text {
              width: 400px;
              // float: right;  
              margin-left: 22px;
              .box-text-top {
                // width: 400px;
                .box-text-time {
                  // float: right;
                }
              }
              .box-text-bottom {
                // margin-top: 15px;
                // height: 68px;
                font-size: 14px;
                padding: 5px 0;
                p {
                  overflow : hidden;
                  text-overflow: ellipsis;
                  display: -webkit-box;
                  -webkit-line-clamp: 2;
                  -webkit-box-orient: vertical;
                }
              }
            }
          }
        }
      }
    }
  }
</style>